#include "Record.h"
#include <cstdlib>
#include <iostream>
using namespace std;

Record::Record(void)
{
}

void Record::AddColumn(std::string val)
{
	_columns.push_back(val);
}

int Record::GetInt(int col)
{
	return atoi(_columns[col].c_str());
}

std::string Record::GetString(int col)
{
	return _columns[col];
}

bool Record::IsEmptyString(std::string str)
{
	size_t i;
	for(i = 0 ; i < str.size(); i++)
	{
		if(str[i] != ' ')
			return false;
	}
	return true;
}

void Record::PrintRecord()
{
	for(size_t i = 0 ; i < this->_columns.size(); i ++)
	{
		if(this->_columns[i].empty())
			cout<<"\"\""<<" ";
		else if(this->_columns[i] == "\f")
			cout<<"<NULL>"<<" ";
		else if(IsEmptyString(this->_columns[i]))
		{
			size_t j;
			cout<<'"';
			for(j = 0; j < this->_columns[i].size(); j++)
				cout<<" ";
			cout<<'"';
			cout<<" ";
		}
		else
			cout<<this->_columns[i]<<" ";
	}
		
	cout<<endl;
}

Record::~Record(void)
{
}
